﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Text;
using System.IO;
using System.Reflection;

namespace mLabTranslate
{
    public class Izbornik
    {
        private string _id;
        public string Id { get { return _id; } set { _id = value; } }

        private string _text;
        public string Text { get { return _text; } set { _text = value; } }
    }

    public static class PrijevodIzbornika
    {
        private static List<Izbornik> labele;

        public static void UcitajFile()
        {
            if (labele == null)
            {
                labele = new List<Izbornik>();

                string filePath = @"..\Izbornik.txt";
                string line;

                if (File.Exists(filePath))
                {
                    StreamReader file = null;
                    try
                    {
                        file = new StreamReader(filePath);
                        while ((line = file.ReadLine()) != null)
                        {
                            string[] words = line.Split(';');
                            Izbornik lbl = new Izbornik();
                            lbl.Id = words[0];
                            lbl.Text = words[1];
                            labele.Add(lbl);
                        }
                    }
                    finally
                    {
                        if (file != null)
                            file.Close();
                    }
                }
            }
        }

        public static string Prevedi(string id)
        {
            UcitajFile();
            return (from line in labele where line.Id == id select line).SingleOrDefault().Text.ToString();
        }
    }
}
